package com.ruoyi.teacher.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TDataInfo;
import com.ruoyi.teacher.service.ITDataInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查看项数据信息集Controller
 *
 * @author xiangzy
 * @date 2022-04-18
 */
@RestController
@RequestMapping("/teacher/dataInfo")
public class TDataInfoController extends BaseController
{
    @Autowired
    private ITDataInfoService tDataInfoService;

    /**
     * 查询查看项数据信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDataInfo tDataInfo)
    {
        startPage();
        List<TDataInfo> list = tDataInfoService.selectTDataInfoList(tDataInfo);
        return getDataTable(list);
    }

    /**
     * 导出查看项数据信息集列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:export')")
    @Log(title = "查看项数据信息集", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDataInfo tDataInfo)
    {
        List<TDataInfo> list = tDataInfoService.selectTDataInfoList(tDataInfo);
        ExcelUtil<TDataInfo> util = new ExcelUtil<TDataInfo>(TDataInfo.class);
        return util.exportExcel(list, "dataInfo");
    }

    /**
     * 获取查看项数据信息集详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(tDataInfoService.selectTDataInfoById(recordid));
    }

    /**
     * 新增查看项数据信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:add')")
    @Log(title = "查看项数据信息集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDataInfo tDataInfo)
    {
        return toAjax(tDataInfoService.insertTDataInfo(tDataInfo));
    }

    /**
     * 修改查看项数据信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:edit')")
    @Log(title = "查看项数据信息集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDataInfo tDataInfo)
    {
        return toAjax(tDataInfoService.updateTDataInfo(tDataInfo));
    }

    /**
     * 删除查看项数据信息集
     */
    @PreAuthorize("@ss.hasPermi('teacher:dataInfo:remove')")
    @Log(title = "查看项数据信息集", businessType = BusinessType.DELETE)
    @DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(tDataInfoService.deleteTDataInfoByIds(recordids));
    }
}
